using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;
using System.Data;
using System.IO;
using MyClever.Lib;

namespace MyClever.DefaultPlugins
{
    public class DeleteFilesPlugin : MissionPlugin
    {
        [Package(Direction.Input, "Defines the files, you like to delete.")]
        enum DeleteFiles
        {
            [Column(typeof(string), "The file you like to delete?")]
            Filename
        }

        [Plugin(PluginDevStatus.Production, "Deletes the given files.")]
        public DeleteFilesPlugin()
        {
        }

        public override void Initialize()
        {
            
            //This is the first Function called by the host...
            //Put anything needed to start with here first
        }

        public override void Dispose()
        {
            //Put any cleanup code in here for when the program is stopped
        }

        /// <summary>
        /// Generate new Source-content.
        /// </summary>
        protected override void Work()
        {
            DataTableReader deleteFiles = this.GetDataReader(typeof(DeleteFiles));
            while (deleteFiles.Read())
            {
                this.AddNewLoggingMessage(typeof(DeleteFiles), String.Format("delete:{0}", deleteFiles[DeleteFiles.Filename.ToString()].ToString()));

                File.Delete(deleteFiles[DeleteFiles.Filename.ToString()].ToString());
            }
        }
    }
}
